<template>
    <div>
        <div class="container">
            <div class="handle-box">
                <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
                    <el-option key="1" label="市场查获" value="市场查获"></el-option>
                    <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
                    <el-option key="3" label="上级交办" value="上级交办"></el-option>
                </el-select>
                <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
                    <el-option key="1" label="一般案件" value="一般案件"></el-option>
                    <el-option key="2" label="简易案件" value="简易案件"></el-option>
                </el-select>
                <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
                <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
            </div>
            <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
                <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
                <el-table-column prop="case_number" label="立案编号" width="200"  align="center"></el-table-column>
                <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
                <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
                <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
                <el-table-column label="行政处罚事先告知书状态" align="center" width="200">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '案件处理审批已完成' ">
                            <el-tag :type=" 'danger'">案件处理审批已完成</el-tag>
                        </div>
                        <div v-if="scope.row.tcs_note_id === '行政处罚事先告知书确认完成' ">
                            <el-tag :type=" 'danger'">行政处罚事先告知书确认完成</el-tag>
                        </div>


                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id === '无证经营公示已完成' ||
                                scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书已完成'||
                                scope.row.tcs_note_id ==='行政罚款收据上传完成'||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-tag :type=" 'success'">已完成 </el-tag>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="下一步操作" width="375px" align="center">
                    <template #default="scope">
                        <div v-if="scope.row.tcs_note_id === '案件处理审批已完成' ">
                            <el-button text :icon="Edit" class="blue" @click="advance_notice_table(scope.row)" >
                                行政处罚事先告知书查看及确认
                            </el-button>

                        </div>
                        <div v-if="scope.row.tcs_note_id === '行政处罚事先告知书确认完成' ">
                            <el-button text :icon="Edit" class="blue" @click="advance_arrive_document_tabel(scope.row)">
                                行政处罚事先告知书送达文书填写
                            </el-button>
                        </div>

                        <div v-if="scope.row.tcs_note_id === '已完成' ||
                                scope.row.tcs_note_id === '无证经营公示已完成' ||
                                scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
                                scope.row.tcs_note_id ==='行政处罚决定书已完成'||
                                scope.row.tcs_note_id ==='行政罚款收据上传完成'||
                                scope.row.tcs_note_id ==='行政罚款收据已完成'||
                                scope.row.tcs_note_id ==='结案报告表已完成'">
                            <el-button text :icon="Edit" class="blue" @click="advance_notice_browse(scope.row)" >
                                查看行政处罚事先告知书
                            </el-button>
                            <el-button text :icon="Edit" class="blue" @click="advance_arrive_document_browse(scope.row)" >
                                查看送达回证
                            </el-button>

                        </div>


                    </template>
                </el-table-column>
            </el-table>
          <div class="pagination">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page="query.pageIndex"
                :page-size="query.pageSize"
                :total="pageTotal"
                @current-change="handlePageChange"
            ></el-pagination>
          </div>
        </div>

        <el-dialog title="送达文书填写" v-model="Advance_notice_arrive_document_Visible" width="45%">
            <el-form ref="form"  :model="form" label-width="100px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达文书名称">
                            <el-input v-model="advance_arrive_document_data.arrive_document_name" :disabled="true" ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="文书文号">
                            <el-input v-model="advance_arrive_document_data.arrive_number" :disabled="true"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="受送达人">
                            <el-input  v-model="advance_arrive_document_data.addressee"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达方式">
                            <el-input  v-model="advance_arrive_document_data.service_mode"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="advance_arrive_document_data.arrive_person1" @change="get_interrogator_clause_opinion(advance_arrive_document_data.arrive_person1)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="advance_arrive_document_data.arrive_person2"  @change="get_interrogator_clause_opinion(advance_arrive_document_data.arrive_person2)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-form-item label="送达地点">
                    <el-input v-model="advance_arrive_document_data.arrive_place"  type="textarea" rows="2"></el-input>
                </el-form-item>
                <el-form-item label="收件人签章">
                    <el-input v-model="advance_arrive_document_data.receipt_signature" type="textarea" rows="2"></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="签收日期">
                            <el-date-picker v-model="advance_arrive_document_data.receipt_time"   type="datetime" placeholder="选择签收日期" value-format="YYYY-MM-DD HH:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达日期">
                            <el-date-picker v-model="advance_arrive_document_data.arrive_time"   type="datetime" placeholder="选择签收日期" value-format="YYYY-MM-DD HH:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-form-item label="代收理由">
                    <el-input type="textarea" rows="2" v-model="advance_arrive_document_data.subsitute_reason"></el-input>
                </el-form-item>
                <el-form-item label="见证人签章">
                    <el-input type="textarea" rows="2" v-model="advance_arrive_document_data.witness_signature"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" rows="2" v-model="advance_arrive_document_data.remarks" ></el-input>
                </el-form-item>

            </el-form>

            <template #footer>
              <span class="dialog-footer">
                  <el-button @click="Advance_notice_arrive_document_Visible = false">取 消</el-button>
        <el-button type="primary" @click="certain_arrive_document">确 定</el-button>
              </span>
            </template>
        </el-dialog>


        <el-dialog title="行政处罚事先告知书填写" v-model="Advance_notice_Visible" width="42%">
            <el-form ref="form"  :model="form" label-width="100px">
                <el-form-item label="案由">
                    <el-input v-model="advance_notice_data_storage.illegal_behavior" :disabled="true"></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="当事人">
                            <el-input v-model="advance_notice_data_storage.tir_person"  :disabled="true" ></el-input>
                        </el-form-item>

                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="性别">
                            <el-input  v-model="advance_notice_data_storage.tir_gender" :disabled="true" ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="年龄">
                            <el-input v-model="advance_notice_data_storage.tir_age"  :disabled="true" ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item label="户籍地址">
                    <el-input v-model="advance_notice_data_storage.household_registration" type="textarea" rows="2"  :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="身份证号">
                    <el-input v-model="advance_notice_data_storage.tir_id_number"  :disabled="true" ></el-input>
                </el-form-item>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="许可证号">
                            <el-input v-model="advance_notice_data_storage.retail_licence_code"  :disabled="true" ></el-input>
                        </el-form-item>

                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="填写时间">
                            <el-date-picker  v-model="advance_notice_data_storage.write_time"  type="datetime" placeholder="选择填写日期" value-format="YYYY-MM-DD HH:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="advance_notice_data_storage.staff_deliverer1"  @change="get_interrogator_clause_opinion(advance_notice_data_storage.staff_deliverer1)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="送达人">
                            <el-select v-model="advance_notice_data_storage.staff_deliverer2"  @change="get_interrogator_clause_opinion(advance_notice_data_storage.staff_deliverer2)" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="(item,index) in interrogator_Data"
                                        :key='index'
                                        :label='item.staff_name'
                                        :value='item.staff_id'
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                </el-row>

                <el-form-item label="违反法律">
                    <el-input :disabled="true" v-model="advance_notice_data_storage.violate_law"  type="textarea" rows="4"></el-input>
                </el-form-item>
                <el-form-item label="处罚决定">
                    <el-input :disabled="true" v-model="advance_notice_data_storage.penalty_decision" type="textarea" rows="2"></el-input>
                </el-form-item>

                <el-form-item  label="处罚依据">
                    <el-input :disabled="true" v-model="advance_notice_data_storage.punish_basis" type="textarea" rows="2"></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
              <span class="dialog-footer">
                  <el-button @click="Advance_notice_Visible = false">取 消</el-button>
        <el-button type="primary" @click="certain_advance_notice">确 定</el-button>
              </span>
            </template>
        </el-dialog>


        <!--    行政处罚事先告知书送达回证-->
        <el-dialog title="" v-model="View_Advance_arrive_document_Visible" width="38%" >
            <html>
            <head>
                <title>送&nbsp;&nbsp;&nbsp;达&nbsp;&nbsp;&nbsp;回&nbsp;&nbsp;&nbsp;证</title>
            </head>
            <body>
            <h1 align="center">
                福建省闽侯县烟草专卖局
            </h1>
            <h1 align="center">
                送达回证
            </h1>
            <div align="center">
                <font size="3">
                    侯烟送[{{advance_arrive_document_data.year}}]第{{advance_arrive_document_data.case_number}}号
                </font>
            </div>
            <table border="1" style="border-collapse: collapse;" width="100%">
                <tr>
                    <th height="50" width="14%">送达文书名称</th>
                    <th  width="36%" >{{advance_arrive_document_data.arrive_document_name}}</th>
                    <th width="14%">送达文书文号</th>
                    <th width="36%">{{advance_arrive_document_data.arrive_number}}</th>
                </tr>
                <tr>
                    <th height="35">受送达人</th>
                    <th colspan="3">{{advance_arrive_document_data.addressee}}</th>
                </tr>
                <tr>
                    <th height="50">送达地点</th>
                    <th colspan="3">{{advance_arrive_document_data.arrive_place}}</th>
                </tr>
                <tr>
                    <th height="35">送达方式</th>
                    <th colspan="3">{{advance_arrive_document_data.service_mode}}</th>
                </tr>
                <tr>
                    <th height="60">收件人签名或盖章</th>
                    <th colspan="3">{{advance_arrive_document_data.receipt_signature}}</th>
                </tr>
                <tr>
                    <th height="45">签收日期</th>
                    <th colspan="3">{{advance_arrive_document_data.year1}}&nbsp;年&nbsp;{{advance_arrive_document_data.month1}}&nbsp;月&nbsp;{{advance_arrive_document_data.day1}}&nbsp;日&nbsp;
                        {{advance_arrive_document_data.hour1}}&nbsp;时&nbsp;{{advance_arrive_document_data.min1}}&nbsp;分</th>
                </tr>
                <tr >
                    <th height="55">代收人注明代收理由</th>
                    <th colspan="3">{{advance_arrive_document_data.subsitute_reason}}</th>
                </tr>
                <tr>
                    <th height="35">见证人签名或盖章</th>
                    <th colspan="3">{{advance_arrive_document_data.witness_signature}}</th>
                </tr>
                <tr>
                    <th height="35">送达人签名</th>
                    <th colspan="3">{{advance_arrive_document_data.staff_name1}}&nbsp;:&nbsp;{{advance_arrive_document_data.staff_license_no1}}&nbsp;
                        {{advance_arrive_document_data.staff_name2}}&nbsp;:&nbsp;{{advance_arrive_document_data.staff_license_no2}}</th>
                </tr>
                <tr>
                    <th height="35">送达日期</th>
                    <th colspan="3">{{advance_arrive_document_data.year2}}&nbsp;年&nbsp;{{advance_arrive_document_data.month2}}&nbsp;月&nbsp;{{advance_arrive_document_data.day2}}&nbsp;日&nbsp;
                        {{advance_arrive_document_data.hour2}}&nbsp;时&nbsp;{{advance_arrive_document_data.min2}}&nbsp;分</th>
                </tr>
                <tr>
                    <th height="70">备&nbsp;&nbsp;&nbsp;&nbsp;注</th>
                    <th colspan="3">{{advance_arrive_document_data.remarks}}</th>
                </tr>


            </table>
            </body>
            </html>
            <template #footer>
				<span class="dialog-footer">
                  <el-button @click="View_Advance_arrive_document_Visible=false" >取 消</el-button>
          <el-button type="primary" :icon="Printer" @click="advance_arrive_document_print">打 印</el-button>
				</span>
            </template>
        </el-dialog>


        <!--行政处罚事先告知书-->
        <el-dialog title="" v-model="Advance_notice_penalty_Visible" width="34%">
            <html>
            <head>
                <title>行政处罚事先告知书</title>
            </head>
            <body>
            <h1 align="center">
                福建省闽侯县烟草专卖局
            </h1>
            <h2 align="center">
                行政处罚事先告知书
            </h2>
            <div align="center">
                <font size="3">侯烟处告[<strong>{{advance_notice_penalty_data.year}}</strong>]第 <strong>{{advance_notice_penalty_data.case_number}} </strong>号</font>
            </div>
            &nbsp;
            <div > <strong>
                <font size="3">
                    案由：{{advance_notice_penalty_data.illegal_behavior}}
                </font>
            </strong>
            </div>

            <div >
                <strong>
                    <font size="3">
                        当事人：{{advance_notice_penalty_data.tir_person}}&nbsp;&nbsp;&nbsp;&nbsp;性别：{{advance_notice_penalty_data.tir_gender}}&nbsp;&nbsp;&nbsp;&nbsp;年龄：{{advance_notice_penalty_data.tir_age}}周岁
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        户籍地址：{{advance_notice_penalty_data.mer_hometown}}
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        身份证号：{{advance_notice_penalty_data.tir_id_number}}
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        烟草专卖许可证号：{{advance_notice_penalty_data.retail_licence_code}}
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;经查，你于{{advance_notice_penalty_data.year}}年{{advance_notice_penalty_data.month}}月{{advance_notice_penalty_data.day}}日，因{{advance_notice_penalty_data.illegal_behavior}}的行为，违反了{{advance_notice_penalty_data.violate_law}}，
                        构成了{{advance_notice_penalty_data.illegal_behavior}}的事实，根据《中华人民共和国行政处罚法》第二十八条规定，现责令当事人改正上述行为。并根据{{advance_notice_penalty_data.punish_basis}}的规定，我局拟对你做出处罚如下：对当事人{{advance_notice_penalty_data.tir_person}}{{advance_notice_penalty_data.illegal_behavior}}的违法行为，{{advance_notice_penalty_data.bureau_penalty}}
                    </font>
                </strong>
            </div>
            <div >
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;根据《中华人民共和国行政处罚法》第四十四条、第四十五条的规定，你享有陈述权和申辩权和要求听证的权利。如需要陈述和申辩，应在收到本告知书之日起三日内向本局提出。
                        逾期未提出的，视为自动放弃此权利。请书写你的陈述和申辩意见，并签署姓名和日期。
                    </font>
                </strong>
            </div>
            <br>
            <div align="right">
                <strong>
                    <font size="3">
                        福建省闽侯县烟草专卖局
                    </font>
                </strong>
            </div>
            <div align="right">
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 年&nbsp;&nbsp; 月&nbsp;&nbsp; 日
                    </font>
                </strong>
            </div>

            <div >
                <strong>
                    <font size="3">
                        你有什么要陈述和申辩的吗？
                    </font>
                </strong>
            </div>
            &nbsp;
            <div >
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当事人：______________________________________________________________________________________________
                    </font>
                </strong>
            </div>
            <br>
            <div >
                <strong>
                    <font size="3">
                        当事人签字：
                    </font>
                </strong>
            </div>
            <div align="right">
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 年&nbsp;&nbsp; 月&nbsp;&nbsp; 日&nbsp;&nbsp; 时&nbsp;&nbsp; 分
                    </font>
                </strong>
            </div>
            &nbsp;<br>
            <div >
                <strong>
                    <font size="3">
                        送达人：
                    </font>
                </strong>
            </div>
            <div align="center">
                <strong>
                    <font size="3">
                        执法证号：{{advance_notice_penalty_data.staff_license_no1}}
                    </font>
                </strong>
            </div>
            <div align="center">
                <strong>
                    <font size="3">
                        执法证号：{{advance_notice_penalty_data.staff_license_no2}}
                    </font>
                </strong>
            </div>
            <br>
            <div align="right">
                <strong>
                    <font size="3">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 年&nbsp;&nbsp; 月&nbsp;&nbsp; 日&nbsp;&nbsp; 时&nbsp;&nbsp; 分
                    </font>
                </strong>
            </div>
            </body>
            </html>
            <template #footer>
				<span class="dialog-footer">
					<el-button @click="Advance_notice_penalty_Visible = false">取 消</el-button>
          <el-button :icon="Printer" type="primary" @click="create_advance_notice_penalty_word">打 印</el-button>
				</span>
            </template>
        </el-dialog>




    </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus,Printer } from '@element-plus/icons-vue';
import {
    case_evi_Create,
    case_evi_Views,
    case_legal_Create,
    ciga_evudence_Create,
    end_record_data,
    evi_Views,
    fetchData_case,
    fetchData_case_Create,
    fetchData_case_update,
    fetchData_legal_clause,
    fetchData_mer,
    fetchData_s_mongodb_evidence_Cre,
    fetchData_s_mongodb_evidence_Views,
    fetchData_tobacco,
    fetchData_user,
    illegal_record_data,
    illegal_record_Search,
    mer_Create,
    mer_search_api,
    review_price_data,
    staff_evidence_create,
    staff_evidence_data,
    end_record_show,
    record_inquiry_show,
    record_inquiry_print,
    case_evidence_Views,
    case_evidence_Edit,
    question_answer_clause_delete,
    price_review_clause_delete,
    fetchData_user_Edit,
    fetchData_price_Edit,
    hearing_arrive_document,
    fetchData_interrogator_clause,
    fetchData_inquiry_record_Confirm,
    fetchData_arrive_document_Confirm,
    hearing_notice_data,
    fetchData_hearing_notice_Confirm,
    hearing_notice_browse_data,
    penalty_advance_notice_data,
    fetchData_advance_notice_Confirm,
    advance_arrive_document,
    advance_penalty_data,
    arrive_document_print_data
} from '../api/index';
import {
    export_word_16, export_word_15,
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
    case_id:number,
    date_of_filing:string,
    date_of_closing:string,
    date_of_archive:string,
    case_source:string,
    case_number:string,
    archive_person:string,
    case_update_time:string,
    ase_type:string,
    case_remark:string,
    tcs_note_id:string,
    ciga_flag:string,
    ciga_num_flag:string,
    mer_flag:string,
}

//案件暂存数据
const create_case = reactive({
    case_id:0,
    staff_evi_id:0,
    staff_id:0,
    staff_evi_send_per:'',
    staff_evi_check_per1:'',
    staff_evi_check_per2:'',
    staff_evi_send_time:'',
    staff_evi_send_unit:'',
    staff_evi_send_result:'',
    staff_evi_rec_address:'',
    staff_evi_status:'',
    staff_evi_per_note:'',
    mer_flag:'',
    ciga_num_flag:'',
    ciga_flag:'',
    test:[],
    img_data:'',
    standard:'',
    tir_id:0,
    tlc_id:0,
    illegal_behavior:'',
    evi_id_number:'',
    evi_id:'',
    date_of_filing:'',
    date_of_closing:'',
    date_of_archive:'',
    case_source:'',
    case_number:'',
    archive_person:'',
    case_update_time:'',
    case_type:'',
    case_remark:'',
    mer_id:0,
    tcs_note:'',
    cs_note:'',
    tce_time:'',
    tce_number:0,
    tce_amount:0,
    tce_remark:'',
    tce_address:'福建省福州市闽侯县烟草专卖局',
    evi_number:0,//数量(条)
    ciga_variety:'',//品种
    barcode:'',//条形码
    ciga_model:'',//规格型号
    ciga_price:0,//单价
    inkjet:'',//
    mer_format:'',
    mer_address:'',
    mer_person:'',
    mer_record:'',
    date_of_record:'',
    date_of_effect:'',
    date_of_issue:'',
    mer_hometown:'',
    mer_id_number:'',
    mer_tel:'',
    business_licence_code:'',
    licence_state:'',
    storage_address:'',
    retail_licence_code:'',
    category:'',
    area_id:0,
    mer_zip_code:0,
    mer_name:'',
    remark:'',
});
//获取商户数据用作选项框
interface mer_data {
    mer_id: number,
    mer_format: string,
    mer_address: string,
    mer_person: string,
    mer_record: string,
    date_of_record: string,
    date_of_effect: string,
    date_of_issue: string,
    mer_hometown: string,
    mer_id_number: string,
    mer_tel: string,
    business_licence_code: string,
    licence_state: string,
    storage_address: string,
    retail_licence_code: string,
    category: string,
    area_id: number,
    mer_zip_code: number,
    mer_name: string,
}
const mer_Data = ref<mer_data[]>([]);
const get_mer_opinion = (mer_name:string='',licence_state:string='',mer_person:string='' ,mer_id:number,business_licence_code:string='') =>{
    fetchData_mer(mer_name,licence_state,mer_person,mer_id,business_licence_code).then(res =>{
        mer_Data.value = res.data.data;
    })
}
get_mer_opinion();
//获取执法人员数据作为选择框
interface staff_data{
    staff_id:number,
    staff_name:string,
    staff_gender:string,
    staff_birthday:string,
    staff_ethnicity:string,
    staff_edu_bg:string,
    staff_email:string,
    field_staff_identity_card:string,
    staff_hometown:string,
    staff_degree:string,
    staff_political_status:string,
    staff_post:string,
    staff_account_no:string,
    staff_account_pwd:string,
    staff_starting_time:string,
    staff_authorized:string,
    staff_phone:string,
    staff_tel:string,
    staff_e_sign:string,
    staff_small_number:string,
    staff_license_no:string,
    staff_now_work_degree:string,
    staff_now_evaluate_degree:string,
}
const staff_Data = ref<staff_data[]>([]);
const get_staff_opinion1 = () =>{
    fetchData_user('','','').then(res=>{
        staff_Data.value = res.data.data;
    })
}
get_staff_opinion1();

//获取案由信息数据用作选项框
interface illegal_data {
    tlc_id:number,
    illegal_behavior:string,
    standard:string,
    penalty_range:string,
    statutory_penalty:string,
    grade:string,
    remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
    fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
        illegal_Data.value = res.data.data;
    })
}
get_legal_clause_opinion();


//视图/

const Ratification_Visible = ref(false);                              //批准书视图
const Ratification_Edit_Visible = ref(false);                         //批准书修改视图
const Advice_note_Visible = ref(false);                               //通知书视图
const Advice_note_Views_Visible = ref(false);                         //查看通知书视图
const Price_list_Visible = ref(false);                                //核价表视图
const Price_list_Browse_Visible = ref(false);                                //核价表视图
const Hearing_notice_content_Visible=ref(false);                             //听证告知书内容确认视图
const Advance_notice_Visible=ref(false);                                    //行政处罚事先告知书
const Advance_notice_arrive_document_Visible=ref(false);                           //行政处罚事先告知书送达文书视图
const View_Advance_arrive_document_Visible=ref(false);                //行政处罚事先告知书送达回文
const Advance_notice_penalty_Visible=ref(false);                        //行政处罚事先告知书预览




//行政处罚事先告知书暂存记录
const advance_notice_data_storage=reactive({
    illegal_behavior:'',//违法行为
    tir_person:'',
    tir_gender:'',
    tir_age:'',
    household_registration:'',//户籍地址
    tir_id_number:'',
    violate_law:'',//违反法律
    penalty_decision:'',//处罚决定
    punish_basis:'',//处罚依据
    write_time:'',
    staff_deliverer1:'',//送达人1
    staff_deliverer2:'',//送达人2
    retail_licence_code:'',
    staff_license_no1:'',
    staff_license_no2:'',
    hearing_time:'',
    hearing_notice_content:'',
    undertaker1_name:'',
    undertaker2_name:'',
    staff_license_no3:'',
    staff_license_no4:'',
    year:'',
    month:'',
    day:'',
    year1:'',
    month1:'',
    day1:'',
    case_number:'',
})

const get_advance_notice_data_storage=(row:any)=>{
    penalty_advance_notice_data(row.case_id).then(res=>{
        advance_notice_data_storage.illegal_behavior=res.data.data.illegal_behavior;
        advance_notice_data_storage.tir_person=res.data.data.tir_person;
        advance_notice_data_storage.tir_gender=res.data.data.tir_gender;
        advance_notice_data_storage.tir_age=res.data.data.tir_age;
        advance_notice_data_storage.household_registration=res.data.data.household_registration;
        advance_notice_data_storage.tir_id_number=res.data.data.tir_id_number;
        advance_notice_data_storage.retail_licence_code=res.data.data.retail_licence_code;
        advance_notice_data_storage.violate_law=res.data.data.violate_law;
        advance_notice_data_storage.penalty_decision=res.data.data.penalty_decision;
        advance_notice_data_storage.punish_basis=res.data.data.punish_basis;
    })
}



//行政处罚事先告知书送达文书暂存数据
const advance_arrive_document_data=reactive({
    arrive_document_name:'行政处罚事先告知书',
    addressee:'',//受送达人
    arrive_number:'',
    arrive_place:'',//送达地点
    service_mode:'直接送达',//送达方式
    receipt_signature:'',
    receipt_time:'',//签收时间
    subsitute_reason:'',
    witness_signature:'',
    arrive_person1:'',
    arrive_person2:'',//送达人
    arrive_time:'',//送达时间
    remarks:'',//备注
    year:'',
    case_number:'',
    year1:'',
    month1:'',
    day1:'',
    hour1:'',
    min1:'',
    year2:'',
    month2:'',
    day2:'',
    hour2:'',
    min2:'',
    staff_name1:'',
    staff_license_no1:'',
    staff_name2:'',
    staff_license_no2:'',
})


//行政处罚事先告知书暂存数据
const advance_notice_penalty_data = reactive({
    //case_id:0,
    tir_person: '',
    tir_id_number:'',
    tir_nation:'',
    tir_gender:'',
    tir_home:'',
    mer_hometown:'',
    retail_licence_code:'',
    illegal_behavior:'',
    case_number:'',
    date_of_filing:'',
    tir_age:'',
    year:'',
    month:'',
    day:'',
    violate_law:'',
    bureau_penalty:'',
    user_id_1:0,//询问人员1编号
    user_name_1:'',//询问人员1
    user_id_2:0,//询问人员2编号
    user_name_2:'',//询问人员2
    staff_license_no1:'',
    staff_license_no2:'',
    punish_basis:'',
    // evi_id_number:'',
})

const create_advance_notice_penalty_word=()=>{
    export_word_15(
        advance_notice_penalty_data.tir_person,
        advance_notice_penalty_data.tir_id_number,
        advance_notice_penalty_data.tir_nation,
        advance_notice_penalty_data.tir_gender,
        advance_notice_penalty_data.tir_home,
        advance_notice_penalty_data.mer_hometown,
        advance_notice_penalty_data.retail_licence_code,
        advance_notice_penalty_data.illegal_behavior,
        advance_notice_penalty_data.punish_basis,
        advance_notice_penalty_data.tir_age,
        advance_notice_penalty_data.case_number,
        advance_notice_penalty_data.date_of_filing,
        advance_notice_penalty_data.year,
        advance_notice_penalty_data.month,
        advance_notice_penalty_data.day,
        advance_notice_penalty_data.violate_law,
        advance_notice_penalty_data.bureau_penalty,
        advance_notice_penalty_data.user_id_1,
        advance_notice_penalty_data.user_id_2,
        advance_notice_penalty_data.user_name_1,
        advance_notice_penalty_data.user_name_2,
        advance_notice_penalty_data.staff_license_no1,
        advance_notice_penalty_data.staff_license_no2,
    )
}




const get_advance_arrive_document_data=(row:any)=>{
    advance_arrive_document(row.case_id).then(res=>{
        advance_arrive_document_data.addressee=res.data.data.addressee;
        advance_arrive_document_data.arrive_number=res.data.data.arrive_number;
    })
}

//行政处罚事先告知书送达文书填写
const advance_arrive_document_tabel=(row:any)=>{
    create_case.case_id=row.case_id;
    get_advance_arrive_document_data(row);
    Advance_notice_arrive_document_Visible.value=true;
}

const advance_notice_table=(row:any)=>{
    create_case.case_id=row.case_id;
    get_advance_notice_data_storage(row);
    Advance_notice_Visible.value=true;
}




const certain_advance_notice=()=>{
    create_case.tcs_note = "行政处罚事先告知书确认完成"
    fetchData_advance_notice_Confirm(
        create_case.case_id,
        advance_notice_data_storage.illegal_behavior,
        advance_notice_data_storage.tir_person,
        advance_notice_data_storage.tir_gender,
        advance_notice_data_storage.tir_age,
        advance_notice_data_storage.household_registration,
        advance_notice_data_storage.tir_id_number,
        advance_notice_data_storage.retail_licence_code,
        advance_notice_data_storage.violate_law,
        advance_notice_data_storage.penalty_decision,
        advance_notice_data_storage.punish_basis,
        advance_notice_data_storage.write_time,
        advance_notice_data_storage.staff_deliverer1,
        advance_notice_data_storage.staff_deliverer2,

    ).then(res=>{
        if (res.data.message === "success"){
            getData()
            fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                if (res.data.message === "success"){
                    ElMessage.success('行政处罚事先告知书确认完成');
                    getData();
                    Advance_notice_Visible.value = false;
                }else {
                    ElMessageBox.confirm('状态更新失败', '提示', {
                        type: 'warning'
                    })
                }
            })
        }else{
            ElMessageBox.confirm('确认失败', '提示', {
                type: 'warning'
            })
        }
    })
}


const certain_arrive_document=()=>{
    if(advance_arrive_document_data.receipt_time.length==0){
        alert("请选择签收时间")
    }else if(advance_arrive_document_data.arrive_time.length==0){
        alert("请选择送达时间")
    }else{
        create_case.tcs_note="行政处罚事先告知书已完成"
        fetchData_arrive_document_Confirm(
            create_case.case_id,
            advance_arrive_document_data.arrive_document_name,
            advance_arrive_document_data.addressee,
            advance_arrive_document_data.arrive_number,
            advance_arrive_document_data.arrive_place,
            advance_arrive_document_data.service_mode,
            advance_arrive_document_data.receipt_signature,
            advance_arrive_document_data.receipt_time,
            advance_arrive_document_data.subsitute_reason,
            advance_arrive_document_data.witness_signature,
            advance_arrive_document_data.arrive_person1,
            advance_arrive_document_data.arrive_person2,
            advance_arrive_document_data.arrive_time,
            advance_arrive_document_data.remarks
        ).then(res=>{
            if (res.data.message === "success") {
                getData();
                fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
                    if (res.data.message === "success"){
                        ElMessage.success('行政处罚事先告知书已完成');
                        getData();
                        Advance_notice_arrive_document_Visible.value=false;
                    }else {
                        ElMessageBox.confirm('状态更新失败', '提示', {
                            type: 'warning'
                        })
                    }
                })
            }else{
                ElMessageBox.confirm('确认失败', '提示', {
                    type: 'warning'
                })
            }
        })
    }

}



const advance_arrive_document_browse=(row:any)=>{
    get_advance_arrive_document_browse(row);
    View_Advance_arrive_document_Visible.value=true;
}

const get_advance_arrive_document_browse=(row:any)=>{
    create_case.case_id = row.case_id;
    arrive_document_print_data(create_case.case_id,advance_arrive_document_data.arrive_document_name).then(res=>{
        advance_arrive_document_data.year=res.data.data.year,
        advance_arrive_document_data.case_number=res.data.data.case_number,
        advance_arrive_document_data.arrive_document_name=res.data.data.arrive_document_name,
        advance_arrive_document_data.arrive_number=res.data.data.arrive_number,
        advance_arrive_document_data.addressee=res.data.data.addressee,
        advance_arrive_document_data.arrive_place=res.data.data.arrive_place,
        advance_arrive_document_data.service_mode=res.data.data.service_mode,
        advance_arrive_document_data.receipt_signature=res.data.data.receipt_signature,
        advance_arrive_document_data.year1=res.data.data.year1,
        advance_arrive_document_data.month1=res.data.data.month1,
        advance_arrive_document_data.day1=res.data.data.day1,
        advance_arrive_document_data.hour1=res.data.data.hour1,
        advance_arrive_document_data.min1=res.data.data.min1,
        advance_arrive_document_data.year2=res.data.data.year2,
        advance_arrive_document_data.month2=res.data.data.month2,
        advance_arrive_document_data.day2=res.data.data.day2,
        advance_arrive_document_data.hour2=res.data.data.hour2,
        advance_arrive_document_data.min2=res.data.data.min2,
        advance_arrive_document_data.subsitute_reason=res.data.data.subsitute_reason,
        advance_arrive_document_data.witness_signature=res.data.data.witness_signature,
        advance_arrive_document_data.staff_name1=res.data.data.staff_name1,
        advance_arrive_document_data.staff_license_no1=res.data.data.staff_license_no1,
        advance_arrive_document_data.staff_name2=res.data.data.staff_name2,
        advance_arrive_document_data.staff_license_no2=res.data.data.staff_license_no2,
        advance_arrive_document_data.remarks=res.data.data.remarks
    })
}



//获取询问人
interface interrogator_data{
    staff_id:number,
    staff_name:string
}
//获取询问者选择框
const interrogator_Data=ref<interrogator_data[]>([]);
const get_interrogator_clause_opinion=(staff_id:number,staff_name:string='')=>{
    fetchData_interrogator_clause(staff_id,staff_name).then(res=>{
        interrogator_Data.value=res.data.data
    })
}
get_interrogator_clause_opinion()


const advance_arrive_document_print=()=>{
    arrive_document_print_data(create_case.case_id,advance_arrive_document_data.arrive_document_name).then(res=>{
        export_word_16(
            res.data.data.year,
            res.data.data.case_number,
            res.data.data.arrive_document_name,
            res.data.data.arrive_number,
            res.data.data.addressee,
            res.data.data.arrive_place,
            res.data.data.service_mode,
            res.data.data.receipt_signature,
            res.data.data.year1,
            res.data.data.month1,
            res.data.data.day1,
            res.data.data.hour1,
            res.data.data.min1,
            res.data.data.year2,
            res.data.data.month2,
            res.data.data.day2,
            res.data.data.hour2,
            res.data.data.min2,
            res.data.data.subsitute_reason,
            res.data.data.witness_signature,
            res.data.data.staff_name1,
            res.data.data.staff_license_no1,
            res.data.data.staff_name2,
            res.data.data.staff_license_no2,
            res.data.data.remarks
        )
    })
}



const advance_notice_browse=(row:any)=>{
    create_case.case_id=row.case_id;
    get_advance_notice_browse_data(row);
    Advance_notice_penalty_Visible.value=true;
}


const get_advance_notice_browse_data=(case_id:number)=>{
    advance_penalty_data(create_case.case_id).then(res=>{
        advance_notice_penalty_data.tir_person=res.data.data.tir_person;
        advance_notice_penalty_data.tir_id_number=res.data.data.tir_id_number;
        advance_notice_penalty_data.tir_nation=res.data.data.tir_nation;
        advance_notice_penalty_data.tir_gender=res.data.data.tir_gender;
        advance_notice_penalty_data.tir_home=res.data.data.tir_home;
        advance_notice_penalty_data.mer_hometown=res.data.data.mer_hometown;
        advance_notice_penalty_data.retail_licence_code=res.data.data.retail_licence_code;
        advance_notice_penalty_data.illegal_behavior=res.data.data.illegal_behavior;
        advance_notice_penalty_data.case_number=res.data.data.case_number;
        advance_notice_penalty_data.date_of_filing=res.data.data.date_of_filing;
        advance_notice_penalty_data.year=res.data.data.year;
        advance_notice_penalty_data.tir_age=res.data.data.tir_age;
        advance_notice_penalty_data.punish_basis=res.data.data.punish_basis;
        advance_notice_penalty_data.month=res.data.data.month;
        advance_notice_penalty_data.day=res.data.data.day;
        advance_notice_penalty_data.violate_law=res.data.data.violate_law;
        advance_notice_penalty_data.bureau_penalty=res.data.data.bureau_penalty;
        advance_notice_penalty_data.user_id_1=res.data.data.user_id_1;
        advance_notice_penalty_data.user_id_2=res.data.data.user_id_2;
        advance_notice_penalty_data.user_name_1=res.data.data.user_name_1;
        advance_notice_penalty_data.user_name_2=res.data.data.user_name_2;
        advance_notice_penalty_data.staff_license_no1=res.data.data.staff_license_no1;
        advance_notice_penalty_data.staff_license_no2=res.data.data.staff_license_no2;
    })
}






const img_form_data = reactive({
    case_number: '',
    name:'',
    content:'',
    remark:'',
    img:'',
});
const img = [];
const handleChange = (file) =>{
    img.push(file);
}
const handleRemove = (file) =>{
    img.forEach(function (item,index,arr){
        if (item.name == file.name){
            img.splice(index,1)
        }
    })
}


const advice_note_views = (row:any) =>{
    img_form_data.case_number = row.case_number;
    fetchData_s_mongodb_evidence_Views(row.case_number,"证据先行保存通知书").then(res => {
        img_form_data.img=res.data.data[0].img
        console.log(img_form_data.img)

    });
    Advice_note_Views_Visible.value=true;
}


const query = reactive({
    case_id:0,
    case_source:'',
    case_type:'',
    tcs_note_id:'',
    case_number:'',
    cs_note_id:'',//送达文书状态
    pageIndex: 1,
    pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
    fetchData_case(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
        tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(
            i.tcs_note_id =="无证经营公示已完成" ||
            i.tcs_note_id=="案件处理审批已完成"||
            i.tcs_note_id=="行政处罚事先告知书确认完成"||
            i.tcs_note_id=="行政处罚事先告知书已完成"||
            i.tcs_note_id=="行政处罚决定书确认完成"||
            i.tcs_note_id=="行政处罚决定书已完成"||
            i.tcs_note_id=="行政罚款收据上传完成"||
            i.tcs_note_id=="行政罚款收据已完成"||
            i.tcs_note_id=="结案报告表已完成"||
            i.tcs_note_id=="已完成"
        )  )
      tableList.value = [];
      pageTotal.value = tableData.value.length ;
      // 根据页码确定下标位置
      const index: number = query.pageIndex * query.pageSize - query.pageSize;
      for (let i = index; i < index + query.pageSize; i++) {
        // 防止数组下标越界
        if (i <= tableData.value.length - 1) {
          tableList.value.push(tableData.value[i])
        } else {
          // 越界就不再循环
          break;
        }
      }
    });
};
getData('','','','','','',localStorage.getItem('ms_username'));
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
    getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
    getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}
.handle-box button{
    background-color: #00a854;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}

:deep(.avatar){
    width: 100px;
    height: 100px;
}
.blue {
    color: rgba(0, 118, 252, 0.79);
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.dialog-footer button{
    background-color: #00a854;
    color:white;
}
/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
